package cn.com.pagoda.ideplugin.ui;

import com.intellij.openapi.actionSystem.AnActionEvent;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
 * @author 陈晓涛 on 2023-05-06
 */
public class TextComparisonPanel implements ActionListener {

    private final AnActionEvent anActionEvent;
    private JPanel panel;
    private JPanel toolsPanel;
    private JPanel comparisonPanel;
    private JTextArea leftTextArea;
    private JSplitPane splitPane;
    private JTextArea rightTextArea;
    private JButton refreshButton;

    public TextComparisonPanel(AnActionEvent anActionEvent, JPanel mainPanel) {
        this.anActionEvent = anActionEvent;

        panel = new JPanel(new BorderLayout());

        toolsPanel = new JPanel(new FlowLayout(FlowLayout.LEADING));
        refreshButton = new JButton("对比");
        refreshButton.addActionListener(this);
        toolsPanel.add(refreshButton);
        panel.add(toolsPanel, BorderLayout.NORTH);

        comparisonPanel = new JPanel(new BorderLayout());
        leftTextArea = new JTextArea(30, 60);
        comparisonPanel.add(leftTextArea, BorderLayout.EAST);

        rightTextArea = new JTextArea(30, 60);
        comparisonPanel.add(rightTextArea, BorderLayout.WEST);

        splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftTextArea, rightTextArea);
        comparisonPanel.add(splitPane);

        panel.add(comparisonPanel, BorderLayout.CENTER);

        mainPanel.add(panel, getClass().getSimpleName());
    }

    @Override
    public void actionPerformed(ActionEvent e) {

    }
}
